package com.ithema.service.impl;

import com.ithema.dao.IAccountDao;
import com.ithema.domain.Account;
import com.ithema.service.IAccountService;

import java.sql.SQLException;
import java.util.List;

/**
 * 账户的业务层实现类
 * @author SeRein
 */
public class AccountServiceImpl implements IAccountService {

    private IAccountDao accountDao;

    public AccountServiceImpl() {
    }

    public void setAccountDao(IAccountDao accountDao) {
        this.accountDao = accountDao;
    }

    /**
     * 保存用户
     *
     * @param account
     */
    public void saveAccount(Account account) {
        accountDao.save(account);
    }

    /**
     * 更新账户
     *
     * @param account
     */
    public void updateAccount(Account account) {
        accountDao.update(account);
    }

    /**
     * 删除账户
     *
     * @param accountId
     */
    public void deleteAccount(Integer accountId) {
        accountDao.delete(accountId);
    }

    /**
     * 根据id查询账户
     *
     * @param accountId
     * @return
     */
    public Account findAccountById(Integer accountId) {
        return accountDao.findById(accountId);
    }

    /**
     * 查询所有帐户
     *
     * @return
     */
    public List<Account> findAllAccount()throws SQLException {
        return accountDao.findAll();
    }
}